Skip to content

feat(cat): implement GNU display flags (-A -b -e -E -s -t -T -v)#293

Merged
cramforce merged 3 commits into
vercel-labs:mainfrom
trieloff:implement-cat-show-flags
Jul 12, 2026
Merged

feat(cat): implement GNU display flags (-A -b -e -E -s -t -T -v)#293
cramforce merged 3 commits into
vercel-labs:mainfrom
trieloff:implement-cat-show-flags

Conversation

@trieloff

@trieloff trieloff commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the full GNU coreutils cat display-flag set. Previously cat only supported -n/--number (and advertised the others in flagsForFuzzing without wiring them in, so cat -A errored).

Flag Behavior
-A / --show-all = -vET
-b / --number-nonblank number non-blank lines, overrides -n
-e = -vE
-E / --show-ends $ at end of each line
-s / --squeeze-blank collapse adjacent blank lines
-t = -vT
-T / --show-tabs tabs as ^I
-v / --show-nonprinting ^/M- notation (GNU byte table)
-u accepted, ignored (POSIX no-op)

Details

  • Exact GNU cat.c byte transformation for -v across bytes 0–255 (control chars → ^X, DEL → ^?, high bytes → M- notation). Verified byte-for-byte against GNU coreutils 9.7.
  • Alias expansion (-A=-vET, -e=-vE, -t=-vT), combined short flags (-vET, -An, -bE), and long options.
  • -b overrides -n and numbers only non-blank lines; -s squeezes before numbering; per-line order is [number][transformed content][$ if -E][newline]; trailing partial line gets no $/newline.
  • Byte-clean fast path preserved for the no-flag / -n-only case.
  • --help updated to list all flags; unknown flags still error.

Tests

  • 35 new collocated unit tests across 2 new files (full 0–255 -v byte table, aliases, combos, long options, -u, unknown-flag errors, multi-file numbering, no-trailing-newline).
  • New cat-show.comparison.test.ts with fixtures recorded against GNU coreutils cat 9.7, all entries locked: true so BSD machines won't overwrite.
  • pnpm test:comparison 560/560 · pnpm typecheck · pnpm lint:fix · pnpm knip all clean · cat suite 60/60.

Scope is isolated to packages/just-bash/src/commands/cat/ plus one comparison-test file + fixtures.


Pull Request opened by Augment Code with guidance from the PR author

trieloff added 3 commits July 9, 2026 09:32
Agent-Id: agent-b06ccde0-dadd-446a-8eb7-4da1a3a9a277
Linked-Note-Id: b2ce1141-e925-4ca2-9839-9929c05d6e05
Agent-Id: agent-cb21b343-b39f-4576-af13-6eca0dfea909
Linked-Note-Id: 2f16c18e-02bf-45f0-9c55-ea5a46c11175
Add show-nonprinting/-v byte table, show-ends, show-tabs, squeeze-blank, number-nonblank, long options, and -u no-op, matching GNU coreutils. Includes unit tests and locked comparison fixtures.

Signed-off-by: Lars Trieloff <lars@trieloff.net>
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

@trieloff is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@trieloff trieloff marked this pull request as ready for review July 9, 2026 07:52
@trieloff trieloff requested a review from cramforce as a code owner July 9, 2026 07:52
Copilot AI review requested due to automatic review settings July 9, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cramforce cramforce merged commit 6130334 into vercel-labs:main Jul 12, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants